//题目：https://www.nowcoder.com/practice/7fe2212963db4790b57431d9ed259701?tpId=13&tqId=23280&ru=%2Fpractice%2F6e196c44c7004d15b1610b9afca8bd88&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D13%26type%3D13
//思路：1.层序遍历


#include <algorithm>
#include <climits>
#include <queue>
#include <vector>
#include <stack> 
#include <limits>

using namespace std;
struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};

#include <queue>
class Solution {
public:
    vector<int> PrintFromTopToBottom(TreeNode* root) {
		std::vector<int> res_vec;
		if (root == nullptr) return res_vec;
		std::queue<TreeNode*> t_queue;
		t_queue.push(root);
		while(!t_queue.empty()) {
			auto cur_node = t_queue.front();
			res_vec.push_back(cur_node->val);
			t_queue.pop();
			if (cur_node->left) {
				t_queue.push(cur_node->left);
			}
			if (cur_node->right) {
				t_queue.push(cur_node->right);
			}
		}
		return res_vec;
    }
};

